import java.util.Scanner;

public class CalendarSeeker {
	
	private static enum DayOfTheWeekName {Sunday,Monday,Tuesday,Wednesday,Thursday,Friday;}
	
	public static void main(String[] args) {

		System.out.println("Please enter the date, for example 13 June 2013");

		Scanner input = new Scanner(System.in);

		int day = Integer.parseInt(input.next());
		String monthString = input.next();
		int year = Integer.parseInt(input.next());
		
		DayOfTheWeekName[] values = DayOfTheWeekName.values();
		
		System.out.println("Day of the week is " + values[getDayOfTheWeekNumber(day, monthString, year)]);
	}		
	
	
	private static int getDayOfTheWeekNumber(int day, String monthString, int year) {

		int y = year % 100;
		if (y == 65 && (getMonthNumberBasedOnEnteredMonth(monthString) == 11 || getMonthNumberBasedOnEnteredMonth(monthString) == 12)){
			y = 64;
		}
		int c = year / 100;
		if (c == 20 && (getMonthNumberBasedOnEnteredMonth(monthString) == 11 || getMonthNumberBasedOnEnteredMonth(monthString) == 12)){
			c = 19;
		}
		
		//Formula for the day calculation and vars descriptions can be found here: http://otvet.mail.ru/question/1891423
		//with the correction that if a < 0 then a % b < 0, so if a < 0 the formula would be (a % b + b) % b  
		return ((day + (13 * getMonthNumberBasedOnEnteredMonth(monthString) - 1) / 5 + y + y / 4 + c / 4 - 2 * c) % 7 + 7) % 7;
	}

	
	private static int getMonthNumberBasedOnEnteredMonth(String monthString) {
		return EnumTester.Month.valueOf(monthString.toUpperCase()).ordinal() + 1;
	}
}
